const {omit} = require("lodash");

/**
 * 格式化响应数据
 * @param code
 * @param data
 * @param message
 * @return {{code: number, data, message}}
 */
function formatResponseData(code = 200, data, message) {
    return {
        code,
        data,
        message
    }
}

/**
 * 过滤指定字段
 * @param data
 */
function responseDataOmit(data) {
    return omit({...data['_doc'] ? data['_doc'] : data}, ['_id', '__v'])
}


module.exports = {
    formatResponseData,
    responseDataOmit
}